-- 布朗陶之剑
local bulangtaozhijian = fk.CreateSkill {
    name = "mcdh_bulangtaozhijian",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

bulangtaozhijian:addEffect(fk.TargetSpecified,{
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(self) and player:usedSkillTimes(self.name, Player.HistoryTurn) == 0 and
                data:isOnlyTarget(data.to) and target == player and data.card.is_damage_card
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local card_event = room.logic:getCurrentEvent():findParent(GameEvent.UseCard)
        card_event.bulangtaozhijian = true
        local card_target = data.to
        local targets = room:getOtherPlayers(player)
        for _, p in ipairs(targets) do
            if card_target:isNude() then
                break
            end
            if p ~= card_target then
                local dis = room:askToDiscard(p, {min_num=1,max_num=1,include_equip=true,cancelable=true,skill_name=self.name,prompt="#mcdh_bulangtaozhijian-discard:" .. card_target.id})
                if #dis ~= 0 then
                    local id = room:askToChooseCard(p,{target=card_target,flag="he",skill_name=self.name,cancelable=false} )
                    room:throwCard(id, self.name, card_target, player)
                    room:setPlayerMark(p, "#mcdh_bulangtaozhijia-turn", 1)
                end
            elseif card_target:getHandcardNum() >= 2 then
                local dis = room:askToDiscard(p, {min_num=1,max_num=1,include_equip=true,cancelable=true,skill_name=self.name,prompt="#mcdh_bulangtaozhijian-discard:" .. card_target.id})
                if #dis ~= 0 then
                    local id = room:askToDiscard(p, {min_num=1,max_num=1,include_equip=true,cancelable=true,skill_name=self.name})
                    room:setPlayerMark(p, "#mcdh_bulangtaozhijia-turn", 1)
                end
            end
        end
    end
})

Fk:loadTranslationTable {
    ["mcdh_bulangtaozhijian"] = "族刃",
    [":mcdh_bulangtaozhijian"] = "『布朗陶之剑』<br>每回合限一次，当你使用伤害牌指定唯一目标后，所有其他角色可以依次弃置一张牌并弃置目标角色一张牌。",
    ["#mcdh_bulangtaozhijian-discard"] = "布朗陶之剑：弃置一张牌,弃置 %src 一张牌",
}

return bulangtaozhijian